home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 9.2 KB | 328 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWWindow.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
- // FW_CWindow: Wrapper for a ODWindow.
- //
- // Every FW_CFrame object has a FW_CWindow object associated with it. When
- // FW_CFrame::FacetAdded (not FrameAdded) is called, a new FW_CWindow object is created
- // if the frame doesn't already have one. The FW_CWindow is automatically deleted when
- // FW_CFrame::FrameRemoved is called.
- //
- // You should never directly create a FW_CWindow, ODF will create it for you.
- //
- #ifndef FWWINDOW_H
- #define FWWINDOW_H
-
- // ----- OS Includes -----
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef FWGRDEF_H
- #include "FWGrDef.h"
- #endif
-
- // ----- Foundation Layer -----
-
- #ifndef FWAUTODE_H
- #include "FWAutoDe.h"
- #endif
-
- #ifndef FWRUNTYP_H
- #include "FWRunTyp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef _ODTYPES_
- #include <ODTypes.h>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward Declarations
- //========================================================================================
-
- class FW_CLASS_ATTR ODFrame;
- class FW_CLASS_ATTR FW_CString;
- class FW_CLASS_ATTR FW_CGraphicDevice;
- struct FW_CLASS_ATTR WindowProperties;
- class FW_CLASS_ATTR FW_CMacWindowEvent;
- class FW_CLASS_ATTR ODSession;
-
- //========================================================================================
- // Window style constants
- //========================================================================================
-
- #define FW_kStandardWindow 0x00000001
- #define FW_kOverlappedWindow 0x00000002
- #define FW_kFloatingWindow 0x00000004
- #define FW_kModelessDialog 0x00000008
- #define FW_kModalDialog 0x00000010
-
- #define FW_kSystemDialog 0x00000020
- #define FW_kResizeable 0x00000040
- #define FW_kHasCaption 0x00000080
- #define FW_kHasCloseBox 0x00000100
- #define FW_kHasMaximizeBox 0x00000200
- #define FW_kHasMinimizeBox 0x00000400
-
- //#define FW_kNoStyleWindow 0
- #define FW_kMaximized 0x00001000
- #define FW_kMinimized 0x00002000
-
- //#ifdef FW_BUILD_MAC
- //#define FW_kMacDesktopPane 0x00004000
- //#endif
-
- // Standard document window
-
- #ifdef FW_BUILD_MAC
- #define FW_kDocumentWindow FW_kStandardWindow | FW_kResizeable | FW_kHasCloseBox | FW_kHasMaximizeBox | FW_kHasMinimizeBox
- #else
- // Note - OpenDoc on Windows creates the Shell window for us so and the our window is a child
- // of the shell window. The result is that we don't need any of the adornment that go on a
- // standard overlapped window.
- #define FW_kDocumentWindow FW_kStandardWindow
- #endif
-
- //========================================================================================
- // class FW_CWindow
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CWindow
- {
- public:
- FW_DECLARE_CLASS
-
- public:
- typedef unsigned long WindowStyle;
-
- //----------------------------------------------------------------------------------------
- // Constructors/Destructor
- //
- public:
-
- FW_CWindow(Environment* ev,
- ODPart* thePart,
- ODTypeToken viewType,
- ODTypeToken presentation,
- const FW_CPoint& interiorSize, // in pixels
- const FW_CPoint& position, // in pixels
- WindowStyle style);
- // for document window
-
- FW_CWindow(Environment* ev,
- ODPart* thePart,
- ODFrame* parentFrame,
- FW_Boolean persistent,
- ODTypeToken viewType,
- ODTypeToken presentation,
- const FW_CString& defaultTitle,
- const FW_CPoint& interiorSize, // in pixels
- const FW_CPoint& position, // in pixels
- WindowStyle style);
- // for View As Window
-
- FW_CWindow(Environment* ev,
- ODPart* thePart,
- ODFrame* odFrame);
- // Creates a window from a frame
-
- FW_CWindow(Environment* ev,
- ODPart* thePart,
- ODID windowID);
- // Create a window for non-root frame
-
- virtual ~FW_CWindow();
-
- //----------------------------------------------------------------------------------------
- // From ODWindow (inlines)
- //
- public:
- FW_Boolean IsActive(Environment *ev) const;
- ODPlatformWindow GetPlatformWindow(Environment *ev) const;
-
- void Select(Environment *ev) const;
-
- FW_Boolean IsFloating(Environment* ev) const;
-
- void Close(Environment *ev);
- void CloseAndRemove(Environment *ev);
-
- ODID GetID(Environment *ev) const;
-
- void Show(Environment* ev);
- void Hide(Environment* ev);
- FW_Boolean IsShown(Environment* ev) const;
-
- //----------------------------------------------------------------------------------------
- // New API
- //
- public:
- ODWindow* AcquireODWindow(Environment *ev) const;
-
- // ----- Show/Hide -----
- void ShowHide(Environment* ev,
- FW_Boolean state);
-
- // ----- Graphic Device -----
- FW_CGraphicDevice* GetGraphicDevice(Environment* ev) const;
-
- // ----- Window Title -----
- void GetWindowTitle(Environment* ev,
- FW_CString& windowTiltle) const;
- void SetWindowTitle(Environment* ev,
- const FW_CString& windowTiltle);
-
- // ----- Window Geometry -----
- void SetWindowSize(Environment* ev,
- const FW_CPoint& interiorSize);
- void SetWindowPosition(Environment* ev,
- const FW_CPoint& newPosition);
-
- void GetWindowSize(Environment* ev,
- FW_CPoint& interiorSize) const;
- void GetWindowPosition(Environment* ev,
- FW_CPoint& position) const;
-
- void GetBorderSize(Environment* ev,
- FW_CRect& borderSize) const;
-
- void FitToScreen(Environment* ev);
-
- // ----- Coordinate Conversion -----
- void WindowToScreen(Environment* ev,
- FW_CPoint* points,
- unsigned short nbPoint = 1);
- void ScreenToWindow(Environment* ev,
- FW_CPoint* points,
- unsigned short nbPoint = 1);
-
- void WindowToScreen(Environment* ev,
- FW_CRect& rect);
- void ScreenToWindow(Environment* ev,
- FW_CRect& rect);
-
- // ----- Frame Activation -----
- virtual void HideShowOnActivate(Environment* ev,
- FW_Boolean state);
-
- //----------------------------------------------------------------------------------------
- // Internal Only
- //
- public:
- #ifdef FW_BUILD_MAC
- // ----- Mac Window resizing tracking -----
- void PrivMacTrackResizeWindow(Environment* ev,
- const FW_CRect& growLimits,
- const FW_CMacWindowEvent& windowEvent);
-
- // ----- Mac Window Zooming -----
- void PrivMacDoZoom(Environment* ev,
- const FW_CPoint& zoomedSize,
- const FW_CRect& borderSize,
- const FW_CRect& screenRect,
- unsigned long message);
-
- // ----- Mac Window creation -----
- ODPlatformWindow PrivMacCreatePlatformWindow(Environment* ev,
- Str255 windowTitle,
- const FW_CPoint& interiorSize,
- const FW_CPoint& position,
- unsigned short procID,
- FW_Boolean hasCloseBox);
- #endif
-
- #ifdef FW_BUILD_MAC
- static unsigned short PrivMacStyleToProcId(Environment *ev,
- WindowStyle style);
- #endif
-
- #ifdef FW_BUILD_WIN
- static DWORD PrivWindStyleToWindowsFlags(WindowStyle style);
- static void PrivWindFixSystemMenu(WindowStyle style);
- #endif
-
- // ----- Window information -----
- static void PrivGetBorderSize(ODPlatformWindow platformWindow,
- FW_CRect& borderSize);
-
- protected:
- // ----- ODWindow creation -----
- void PrivCreateODWindow(Environment* ev,
- ODPart* thePart,
- ODFrame* parentFrame,
- FW_Boolean persistent,
- ODTypeToken viewType,
- ODTypeToken presentation,
- const FW_CString& windowTitle,
- const FW_CPoint& interiorSize,
- const FW_CPoint& position,
- WindowStyle style);
-
- void PrivCreateODWindowForFrame(Environment* ev,
- ODPart* odPart,
- ODFrame* odFrame);
-
- void PrivGetDocumentName(Environment* ev,
- ODFrame* sourceFrame,
- FW_CString& title);
-
- //----------------------------------------------------------------------------------------
- // Data Members
- //
- protected:
- ODID fWindowID;
- ODSession* fSession;
-
- FW_CPoint fWindowSize;
- FW_CPoint fWindowPosition;
-
- private:
- FW_CGraphicDevice* fGraphicDevice;
-
- #ifdef FW_BUILD_MAC
- static Handle gMacFloatWindowProc;
- #endif
- };
-
- //========================================================================================
- // Inlines
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CWindow::ShowHide
- //----------------------------------------------------------------------------------------
- inline void FW_CWindow::ShowHide(Environment* ev, FW_Boolean state)
- {
- state ? Show(ev) : Hide(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CWindow::GetID
- //----------------------------------------------------------------------------------------
- inline ODID FW_CWindow::GetID(Environment* ev) const
- {
- return fWindowID;
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-